package com.syq.controller;

import com.syq.dao.DeviceMapper;
import com.syq.dto.R;
import com.syq.dto.SysDeviceDto;
import com.syq.service.SysDeviceService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/devicies")
public class SysDeviceController {

    private SysDeviceService sysDeviceService;

    @Autowired
    public void setSysDeviceService(@RequestBody SysDeviceService sysDeviceService) {
        this.sysDeviceService = sysDeviceService;
    }

    @PostMapping("/device")
    public R addDevice(@RequestBody SysDeviceDto sysDeviceDto){
        sysDeviceService.addDevice(sysDeviceDto);
        return R.setOk();
    }

    @PostMapping("/device/sell/{deviceId}")
    public R update2Sell(String deviceId){
        sysDeviceService.update2Sell(deviceId);
        return R .setOk();
    }
}
